﻿using System;
using System.Configuration;
using System.Web.Http;
using Sustainalytics.DataLayer.ConnectionStrings;
using Sustainalytics.DataLayer.Shared;
using Sustainalytics.Entities;
using Sustainalytics.Entities.ConnectionStrings;
using Sustainalytics.Entities.Governance;
using System.Web.Http.Cors;

namespace Sustainalytics.Governance.Service.Controllers
{
    [EnableCors(origins: "*", headers: "*", methods: "*")]
    [RoutePrefix("api/v1/companyId")]
    public class GovernanceCompanyIndicatorsController:ApiController
    {
        private readonly IRepositoryCollection<GovernanceIssue> _repositoryIssues;
        private readonly IRepositoryCollection<GovernanceComputationResult> _repositoryComputation;
        

        public GovernanceCompanyIndicatorsController()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["ClientPlatform"].ConnectionString;
            var connectionStringsManager =
                ConnectionStringsManager.GetInstance(ConnectionStringsRepository.GetInstance(connectionString));
            _repositoryIssues = new RepositoryCollection<GovernanceIssue>(connectionStringsManager.GetConnectionString(ConnectionStringType.GovernanceDW));
            _repositoryComputation = new RepositoryCollection<GovernanceComputationResult>(connectionStringsManager.GetConnectionString(ConnectionStringType.GovernanceDW));
        }
    }
}
